package com.atcper

import scala.Console.{in, println}

/**
 * @author : ranzlupup
 * @date : 2023/2/22 08:39
 */
object Scala10_Function_Test {

    def main(args: Array[String]): Unit = {

        def test(int1: Int, int2: Int, f: (Int, Int) => Int): Int = {
            f(int1, int2)
        }

        def f(a: Int, b: Int): Int = {
            a + b
        }

        println(test(10, 20, f))
        println(test(10, 20, _ + _))


        def f2(string: String): String = {
            string.substring(0, 1)
        }

        def test1(name: String, f: (String) => String): String = {
            f(name)
        }

        println(test1("ranzili", _.substring(0, 1)))

        val person = new Person("zhb")
        val user1 = new User()
        val user2 = new User("zhb")
        val user3 = new User("zhb", "123123")

        Predef.println()
        Console.println()


    }
}

class Person(var name: String) {
    println("person instance...")
}

object Person {
    def apply(name: String): Person = new Person(name)
}

class User() {
    var username: String = _
    var password: String = _

    def this(name: String) {
        this()
        username = name
        println("我是辅助构造器1...")
    }

    def this(name: String, pwd: String) {
        this(name)
        password = pwd
        println("我是辅助构造器2...")
    }

    println("user instance...")

}